package com.wat4m.jerome.jdpcpool.util;

import java.sql.Connection;
import java.sql.SQLException;

import org.apache.commons.dbcp2.BasicDataSource;

public class DBCPUtil {
	private static Connection conn = null;
	private static BasicDataSource ds = new BasicDataSource();

	static {
		ds.setDriverClassName("org.mariadb.jdbc.Driver");
		ds.setUrl("jdbc:mysql://localhost:3306/store");
		ds.setUsername("root");
		ds.setPassword("123456");
	}

	public static Connection getConnection() {
		try {
			conn = ds.getConnection();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return conn;
	}

	public static void main(String[] args) throws SQLException {
		Connection con = DBCPUtil.getConnection();
		con.close();
	}
}